The present invention relates to a microcomputer and a microcomputer system.
In general, a single-chip microcomputer has a plurality of functional blocks, such as a central processing unit (CPU) as a main unit, and a read only memory (ROM) for storing programs, a random access memory (RAM) for storing data, and an input/output circuit for inputting and outputting data or signals, which are formed on one semiconductor substrate.
The single-chip microcomputer is used for controlling various apparatuses. The single-chip microcomputer controls an engine or the like, for example, via the input/output circuit. During this control, even when the input/output circuit enters an undesired state, it is necessary to prevent malfunction or failure in a control target like the engine. For example, a technique of blocking the output of a timer which is one of input/output circuits to stop the control target has been proposed (Japanese Unexamined Patent Application Publication No. H8-263104).
Moreover, the single-chip microcomputer can construct a high speed and low power consumption system by executing a program on a ROM. In this case, as compared to a scheme which uses an external memory, it is easy to conceal the program content or suppress falsification. However, since a plurality of functional blocks including the ROM have to be formed on one semiconductor substrate, the volume of the ROM that can be mounted is limited. For example, the ROM volume of a single-chip microcomputer is smaller than the storage volume of a hard disk of a personal computer. Thus, in the single-chip microcomputer, it is necessary to select a program and data to be stored in the ROM by taking the ROM volume into consideration. Flash memories are increasingly included as the ROM of the single-chip microcomputer. Since a flash memory can rewrite, whenever necessary, the content stored therein, it is possible to perform debugging, tuning, and upgrading and to improve the usability. For example, the program and data to be stored can be selected appropriately by taking an actual usages into consideration.
In recent years, a magnetoresistive random access memory (MRAM) has been proposed as a memory (nonvolatile random access memory: NVRAM) that is random-accessible and can store information in a nonvolatile manner (Japanese Unexamined Patent Application Publication No. 2002-222589 and Japanese Unexamined Patent Application Publication No. 2004-86986). Data can be read and written (random-accessed) from and to an MRAM similarly to an ordinary RAM. Moreover, it is not necessary to erase data before writing data. As a substitute for a ROM storing data requiring saving and programs in a single-chip microcomputer and a RAM serve as a temporary storage area during work, an MRAM may be included, which can be used to store programs and data requiring saving and also used to serve as a temporary storage area during work.
In a microcomputer, programs and a program (boot program) for writing fixed data may be stored in a rewritable memory (flash memory or NVRAM) that can store data in a nonvolatile manner, and it may be inhibited to read and write data from and to a boot program area during a normal operation. In this way, the boot program area is protected. When a microcomputer is set to a predetermined operation mode (boot mode), the microcomputer executes the boot program to write programs and fixed data (Japanese Unexamined Patent Application Publication No. 2004-318330).
Moreover, a method of performing rewriting when an undesired power failure or the like occurs in a microcomputer or a rewritable and nonvolatile memory during execution of a boot program and it is not possible to properly write data to the memory has been proposed (Japanese Unexamined Patent Application Publication No. 2001-27954). Moreover, a method of controlling writing to a flash memory has been proposed (Japanese Unexamined Patent Application Publication No. 2007-34554).
Further, a technique of performing improper instruction exception handling to execute a predetermined program again after initialization, for example, in order to cope with execution of improper instruction codes due to noise occurring in a microcomputer has been proposed (Japanese Unexamined Patent Application Publication No. 2006-171952). Moreover, a method of performing self-diagnosis in order to detect a failure in hardware of a microcomputer has also been proposed.
In memories such as flash memories, defects may occur due to a failure or deterioration in some memory devices. To cope with such defects, a memory in which an error check and correction (ECC) function is applied to provide redundancy so that the memory can perform a normal operation even when defects occur in some memory devices is proposed (Japanese Unexamined Patent Application Publication No. 2007-241625).